﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TileMapEditor
{
    public enum TriggerType
    {
        [EnumDescription("无")]
        None = 0,//0 无
        [EnumDescription("全局计数器")]
        Global_EventCount = 101,//全局计数器
        [EnumDescription("点击后，移动到相邻格触发")]
        Tile_Click = 201,// 点击触发 
        [EnumDescription("经过触发")]
        Tile_MovePass = 202,// 经过触发 
        [EnumDescription("战斗成功")]
        Battle_End_Success = 301,// 战斗成功
        [EnumDescription("战斗失败")]
        Battle_End_Fail = 302,//战斗失败
        [EnumDescription("交互界面操作完毕")]
        Object_Interact = 401,//物件交互 配一个参数：1 遗物 2 马车 3 泉水 4 复活英雄 5... 
    }

    public enum EffectType
    {
        [EnumDescription("无")]
        None = 0,
        [EnumDescription("战斗")]
        UX_Battle = 101,//战斗界面
        [EnumDescription("获得奖励")]
        Reward = 102,//奖励
        [EnumDescription("交互-遗物选择")]
        UX_BuffBox = 103,//BUFF选择
        [EnumDescription("交互-马车，援助英雄选择")]
        UX_HeroPick = 104,//援助英雄
        [EnumDescription("交互-迷宫货车购物")]
        UX_Cargo = 105,//迷宫货车购物
        [EnumDescription("提示-提示框")]
        Pop_Alert = 201,//提示框
        [EnumDescription("提示-飘字")]
        Pop_Message = 202,//飘字
        [EnumDescription("提示-剧情对话")]
        UX_StoryTeller = 203,//对话
        [EnumDescription("提示-日志")]
        Pop_Log = 204,//对话
        [EnumDescription("数值-血量")]
        Value_ChangeHp = 301,//血量
        //[EnumDescription("数值-能量")]
        //Value_ChangeEnergy = 302,//能量
        [EnumDescription("数值-复活")]
        Value_ChangeResurrect = 303,//复活
        [EnumDescription("地图-格子状态")]
        Map_TileChange = 401,//格子状态 1 加格子 2 减格子 3 加障碍 4 减障碍
        [EnumDescription("地图-加物品")]
        Map_AddObj = 402,//加物品
        [EnumDescription("地图-减物品")]
        Map_RemoveObj = 403,//减物品 
        [EnumDescription("地图-按格子ID减物品")]
        Map_RemoveTileObj = 404,//按格子ID减物品 
        [EnumDescription("特效-屏幕空间特效")]
        Play_ScreenEffect = 501,//屏幕空间特效
        [EnumDescription("特效-格子特效")]
        Play_TileEffect = 502,//格子特效
        [EnumDescription("特效-移除格子特效")]
        RemoveEffect = 601,//移除格子特效
        [EnumDescription("镜头-移镜头")]
        CameraMove = 701,//移镜头
        [EnumDescription("镜头-镜头停止")]
        CameraWait = 702,//移镜头
        [EnumDescription("视野-开视野")]
        SightChange = 801,//开视野
        [EnumDescription("传送")]
        Teleport = 901,//传送
        [EnumDescription("传送到下一层")]
        Teleport_Map = 902,//传送
        [EnumDescription("修改计数器")]
        ChangeCountTime = 1001,//修改计数器
        [EnumDescription("获得指定英雄")]
        AddHeroToBag = 1101,//获得指定英雄
        [EnumDescription("获得指定遗物")]
        AddBuffToBag = 1201,//获得指定遗物
        [EnumDescription("强化敌人")]
        ChangeEnemyState = 1301, //relateId 目标teamId，参数：生命千分比、攻击千分比、防御千分比
        [EnumDescription("移除指定遗物")]
        RemoveBuffFromBag = 1401, //relateId 目标relicId
        [EnumDescription("按筛选条件改变英雄血量和能量")]
        ChangeHpByFilter = 1501, //relateId 改变类型 目前默认为1 主属性
        [EnumDescription("显示或隐藏物件的Spine特效")]
        ShowOrHideSpineEffect = 1601, //relateId 目标物件ID params 1为显示，不填或0为隐藏
        [EnumDescription("播放物件的Spine动画")]
        PlaySpineAnimOnObj = 1602, //relateId 目标物件ID params 动画名称
        [EnumDescription("主角颜色闪动")]
        PlayerTintColor = 1603, //params 颜色（3位，除255） 强度（除100）
    }

    public enum EditTileType
    {
        [EnumDescription("变为联通")]
        AddTile = 1,
        [EnumDescription("变为不联通")]
        RemoveTile = 2
    }

    public enum EditTypeSubType
    {
        [EnumDescription("移除障碍")]
        RemoveBlock = 1,
        [EnumDescription("移除障碍和单元格")]
        RemoveTileBlock = 2,
        [EnumDescription("创建单元格")]
        AddTile = 3
    }

    public enum EffectCameraMoveType
    {
        [EnumDescription("单向")]
        Foward = 0,
        [EnumDescription("往返")]
        FowardBackward = 1,
        [EnumDescription("返回当前位置")]
        Back = 2
    }

    public enum EffectChangeValueType
    {
        [EnumDescription("增量")]
        None = 0,
        [EnumDescription("全量")]
        Override = 1,
    }

    public enum ValueCompareType
    {
        [EnumDescription("小于")]
        Less = 1,
        [EnumDescription("等于")]
        Equal = 2,
        [EnumDescription("大于")]
        MoreThan = 3
    }

    
    [System.Serializable]
    //导出用
    public class TriggerEffectData
    {
        [ReadOnly]
        public int id;
        [ReadOnly]
        public int countTime = -1;//-1为无限次
        [ReadOnly]
        public Trigger trigger;
        [ReadOnly]
        public List<Effect> effects;
        [ReadOnly]
        public List<TriggerRuleCheck> checkRule;

        public TriggerEffectData(TriggerEffect triggerEffect)
        {
            id = triggerEffect.id;
            countTime = triggerEffect.countTime;
            if (triggerEffect.trigger)
            {
                trigger = triggerEffect.trigger;
            }
            if (triggerEffect.effects != null && triggerEffect.effects.Count > 0)
            {
                effects = new List<Effect>();
                for (int i = 0; i < triggerEffect.effects.Count; i++)
                {
                    Effect e = triggerEffect.effects[i];
                    if (e != null)
                    {
                        effects.Add(e);
                    }
                }
            }
            if (triggerEffect.preCheck != null && triggerEffect.preCheck.Count > 0)
            {
                checkRule = new List<TriggerRuleCheck>();
                for (int i = 0; i < triggerEffect.preCheck.Count; i++)
                {
                    TriggerRuleCheck t = triggerEffect.preCheck[i];
                    if (t != null)
                    {
                        checkRule.Add(t);
                    }
                }
            }
        }
    }
}